
const BUSINESS = 'secondLinker'
const RENTING = 'rentalLinker'
const OTHER = 'other'

// label为显示的输入框内容   value为需要使用的参数
const otherAllInfo = [
  { 
    name: '小区',
    isInput: true,
    maxlength: 20,
    unit: '',
    placeholder: '请输入', 
    label: '', 
    value: '', 
    key: 'communityName',
    apply: [BUSINESS, RENTING],
  },
  { 
    name: '户型', 
    isInput: false, 
    unit: '', 
    placeholder: '请选择', 
    label: '', 
    value: '', 
    key: 'room-hall-toilet',
    apply: [BUSINESS, RENTING],
    plugin: function(value) {
      return value.join(" ")
    },
    columns: (function() {
      return [
        {
          defaultIndex: 2,
          values: (function(){
            let array = []
            let min = 1
            let max = 10
            for(let i = min ;i < max; i++) {
              array.push(`${i}室`)
            }
            return array
          })()
        },
        {
          defaultIndex: 2,
          values: (function(){
            let array = []
            let min = 0
            let max = 10
            for(let i = min ;i < max; i++) {
              array.push(`${i}厅`)
            }
            return array
          })()
        },
        {
          defaultIndex: 2,
          values: (function(){
            let array = []
            let min = 0
            let max = 10
            for(let i = min ;i < max; i++) {
              array.push(`${i}卫`)
            }
            return array
          })()
        }
      ]
    })(),
    getAttr(params, index, str) {
      let keys = this.key.split("-")
      keys.forEach((item, i) => {
        params[item] = (+str[i].substr(0, 1))
      })
    },
    parseShow(str) {
      let strs = str.split("/")
      return strs[0] + "室 " + strs[1] + "厅 " + strs[2] + "卫"
    },
    dataLocation(label, index) {
      console.log(index)
      return label.split(" ")[index]
    }
  }, 
  {
    name: '朝向',
    isInput: false, 
    unit: '', 
    placeholder: '请选择', 
    label: '', 
    value: '', 
    key: 'orientationsType',
    apply: [BUSINESS, RENTING],
    columns: (function () {
      return [
        {
          defaultIndex: 2,
          values: ["东", "南", "西", "北", "东南", "西南", "东北", '西北'  ]
        }
      ]
    })(),
    // 朝向【0：不限、1：东、2：南、3：西、4：北、5：东南、6：西南、7：东北、8：西北】
    getAttr(params, indexs) {
      params[this.key] = indexs[0] + 1
    }
  },
  { 
    name: '面积',
    isInput: true,
    unit: '(m²)',
    type: 'number',
    placeholder: '请输入',
    maxlength: 10,
    apply: [BUSINESS, RENTING],
    label: '',
    value: '', 
    key: 'houseArea'
 },
  { 
    name: '价格', 
    isInput: true, 
    unit: '(万)',
    type: 'number',
    maxlength: 10,
    placeholder: '请输入', 
    label: '', 
    value: '', 
    key: 'money',
    apply: [BUSINESS],
  },
  { 
    name: '价格', 
    isInput: true, 
    unit: '(元)',
    type: 'number',
    maxlength: 10,
    placeholder: '请输入', 
    label: '', 
    value: '', 
    key: 'money',
    apply: [OTHER],
  },
  { 
    name: '租金', 
    isInput: true, 
    unit: '(元/月)',
    type: 'number',
    maxlength: 10,
    placeholder: '请输入', 
    label: '', 
    value: '', 
    key: 'money',
    apply: [ RENTING ],
  },
  { 
    name: '楼层', 
    isInput: false, 
    unit: '', 
    placeholder: '请选择', 
    label: '', 
    value: '', 
    key: 'currentFloor-totalFloor',
    apply: [BUSINESS, RENTING],
    columns: (function() {
      return [
        {
          defaultIndex: 2,
          values: (function(){
            let min = 1
            let max = 99
            let array = []
            for(let i = min; i <= max; i++) {
              if (i) array.push(`${i}层`)
            }
            return array
          })()
        },
        {
          defaultIndex: 2,
          values: (function(){
            let min = 1
            let max = 99
            let array = []
            for(let i = min; i <= max; i++) {
              if (i) array.push(`共${i}层`)
            }
            return array
          })()
        }
      ]
    })(),
    plugin: function(values) {
      let [ str1, str2 ] = values
      return str1.substr(0, str1.length-1) + "/" + str2.substr(1, str2.length-2)
    },
    getAttr(params, indexs, str) {
      let keys = this.key.split("-")
      keys.forEach((item, i) => {
        params[item] =  (+str[i].slice(i, str[i].length - 1))
      })
    },
    dataLocation(str, index) {
      let split = str.split("/")
      if (index) {
        return "共" + split[index] + "层"
      } else {
        return  split[index] + "层"
      }
    },
    parseShow(str) {
      return str
    }
  },
  { 
    name: '装修', 
    isInput: false, 
    unit: '', 
    placeholder: '请选择', 
    label: '', 
    value: '', 
    key: 'decorateStatus',
    apply: [BUSINESS, RENTING],
    columns: (function () {
      return [
        {
          defaultIndex: 2,
          values: ["毛坯", "普通装修", "精装修", "豪华装修"],
          // 装修类型【0：不限、1：毛坯、2：普通装修、3：精装修、4：豪华装修】
        }
      ]
    })(),
    getAttr(params, indexs) {
      params[this.key] = indexs[0] + 1
    }
  },
  { 
    name: '电梯', 
    isInput: false, 
    unit: '', 
    placeholder: '请选择', 
    label: '', 
    value: '', 
    key: 'liftStatus',
    apply: [BUSINESS, RENTING],
    columns: (function () {
      return [
        {
          defaultIndex: 0,
          values:  [ "有电梯", "无电梯" ],
          // 电梯【0：不限、1：有电梯、2：无电梯】
        }
      ]
    })(),
    getAttr(params, indexs) {
      params[this.key] = indexs[0] + 1
    }
  },
  { 
    name: '房屋类型', 
    isInput: false, 
    unit: '', 
    placeholder: '请选择', 
    label: '', 
    value: '', 
    key: 'houseType',
    apply: [ BUSINESS ],
    columns: (function () {
      return [
        {
          defaultIndex: 1,
          values:  [ "商品房", "公寓", "别墅", "其它" ],
          // 房屋类型【0：不限、1：商品房、2：公寓、3：别墅、4：其它】
        }
      ]
    })(),
    getAttr(params, indexs) {
      params[this.key] = indexs[0] + 1
    }
  },
  { name: '产权年限', 
    isInput: false, 
    unit: '', 
    placeholder: '请选择', 
    label: '', 
    value: '',
    apply: [BUSINESS],
    key: 'propertyYears',
    columns: (function () {
      return [
        {
          defaultIndex: 1,
          values: [ "70年", "50年", "40年" ],
          // 房屋产权年限【0：不限、1：70年、2：50年、3：40年】
        }
      ]
    })(),
    getAttr(params, indexs) {
      params[this.key] = indexs[0] + 1
    }
  },
]

export default otherAllInfo